package com.city.repository.party;

import com.city.domain.party.PartyLesson;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author  王宇
 * @date 2018/8/12
 * @description  课程表dao层
 */
public interface PartyLessonRepository extends JpaRepository<PartyLesson,Integer>{

    //分页查询
    @Query(value = "select * from party_lesson limit ?1,?2",nativeQuery = true)
    List<PartyLesson> findAllByPage(Integer page, Integer limit);

    @Query(value = "select * from party_lesson where name = ?1",nativeQuery = true)
    PartyLesson findByName(String name);

    //根据时间排序查找所有的课程
    @Query(value = "select * from party_lesson order by update_date desc",nativeQuery = true)
    List<PartyLesson> findByTimeSort();
}
